<?php


namespace app\admin\controller;


use app\common\model\Admin as AdminModel;
use app\common\service\Y;
use think\Request;

class AdminLog extends BaseAdmin
{
    public function index(Request $request) {
        if ($request->isAjax()) {
            $where = [];
            if ($name = input('param.name', 0)) {
                $where[] = ['name', '=', $name];
            }

            if ($path = input('param.path', '')) {
                $where[] = ['path', '=', $path];
            }
            $time = input('param.time', '');
            $data = \app\common\model\AdminLog::with('admin')->where($where)->when($time, function ($query) use($time) {
                $time =  explode(' - ', $time);
                // 满足条件后执行
                $query->whereTime('create_time', 'between', [date('Y-m-d 00:00:00', strtotime($time[0])), date('Y-m-d 23:59:59', strtotime($time[1]))]);
            })->order('id desc')->paginate([
                'list_rows'=> input('param.limit', 10),
                'query' => input('param.')
            ])->toArray();
            return Y::table($data['data'], $data['total']);
        }
        return view();
    }
}